﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <script type="text/javascript">
        function a() {
            var i = 0;
            function b() {
                alert(++i);
            }
            return b;
        }
        
        //第一种写法，两次弹出都是1
        var c = a;
        c()();
        c()();

        //第二种写法，两次弹出的分别是1和2
        var d = a();
        d();
        d();
    </script>
</head>
<body>

</body>
</html>
